package com.showgood.core {
	import com.showgood.util.StringUtil;
	import flash.events.EventDispatcher;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	import flash.utils.getQualifiedClassName;
	
	/**
	 * ...
	 * @author BianPeng
	 */
	public class AbstractMediator extends Mediator {
		import org.as3commons.logging.getLogger;
		import org.as3commons.logging.ILogger;
		protected var _logger:ILogger = getLogger(this);
		// 事件处理
		private var _dispatcher:NotificationDispatcher;
		
		public function AbstractMediator(viewComponent:Object = null) {
			super(getQualifiedClassName(this), viewComponent);
		}
		
		protected function get sangoFacade():SangoFacade {
			return SangoFacade.instance;
		}
		
		/**
		 * 这里把这个封装一下
		 * @return
		 */
		override public function listNotificationInterests():Array {
			if (_dispatcher == null) {
				_dispatcher = new NotificationDispatcher();
				setupNotifactionHandler(_dispatcher);
			}
			return _dispatcher.events;
		}
		
		override public function handleNotification(notification:INotification):void {
			var _type:String = notification.getName();
			var _data:Object = notification.getBody();
			_logger.info(StringUtil.join('deal with dispatched event:',_type,_data));
			_dispatcher.dispatch(new NotificationEvent(_type, _data));
		}
		
		/**
		 * 添加事件处理器
		 * @param	dispatcher
		 */
		protected function setupNotifactionHandler(dispatcher:NotificationDispatcher):void {
		
		}
	}

}
